home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DUProjects / Data / Sources / Part.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.6 KB  |  156 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //    Release Version:    $ ODF 1 $
  3. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  4.  
  5. //================================================================================
  6. #include "Data.hpp"
  7.  
  8. #ifndef PART_H
  9. #include "Part.h"
  10. #endif
  11.  
  12. #ifndef CONTENT_H
  13. #include "Content.h"
  14. #endif
  15.  
  16. #ifndef BINDING_K
  17. #include "Binding.k"
  18. #endif
  19.  
  20. #ifndef FRAME_H
  21. #include "Frame.h"
  22. #endif
  23.  
  24. // ----- Framework Layer -----
  25. #ifndef FWPRESEN_H
  26. #include "FWPresen.h"        // FW_CPresentation
  27. #endif
  28.  
  29. #ifndef FWUTIL_H
  30. #include "FWUtil.h"            // FW_Beep()
  31. #endif
  32.  
  33. #ifndef FWABOUT_H
  34. #include "FWAbout.h"        //::FW_About()
  35. #endif
  36.  
  37. // ----- OS Layer -----
  38. #ifndef FWMENU_H
  39. #include "FWMenu.h"            // FW_CMenuBar, FW_CPullDownMenu
  40. #endif
  41.  
  42. #ifndef FWCFMRES_H
  43. #include "FWCFMRes.h"        // FW_CSharedLibraryResourceFile
  44. #endif
  45.  
  46. #ifndef FWRESTYP_H
  47. #include "FWResTyp.h"        // MULTISTRINGRES
  48. #endif
  49.  
  50. #ifndef FWEVENT_H
  51. #include "FWEvent.h"        // FW_CMenuEvent
  52. #endif
  53.  
  54. #ifndef FWSUSINK_H
  55. #include "FWSUSink.h"        // FW_CStorageUnitSink
  56. #endif
  57.  
  58. #ifndef FWBARRAY_H
  59. #include "FWBArray.h"        // FW_CByteArray
  60. #endif
  61.  
  62. // ----- Foundation Layer -----
  63. #ifndef FWSTREAM_H
  64. #include <FWStream.h>        // FW_InitializeArchiving
  65. #endif
  66.  
  67. #ifndef FWMEMMGR_H
  68. #include "FWMemMgr.h"        // FW_CMemoryManager
  69. #endif
  70.  
  71. #ifndef FWSUSINK_H
  72. #include "FWSUSink.h"        // FW_CStorageUnitSink
  73. #endif
  74.  
  75. //--- OpenDoc ------------------------------------------------------------------
  76. #ifndef SOM_Module_OpenDoc_StdProps_defined
  77. #include <StdProps.xh>        // kODPropContents
  78. #endif
  79.  
  80. //==============================================================================
  81. #ifdef FW_BUILD_MAC
  82. #pragma segment Data
  83. #endif
  84.  
  85. FW_DEFINE_AUTO(CDataPart)
  86.  
  87. //==============================================================================
  88. CDataPart::CDataPart(ODPart* odPart)
  89.   :    FW_CPart(odPart, FW_gInstance, kPartInfoID),
  90.     fPresentation(NULL),
  91.     fPartContent(NULL)
  92. {
  93. }
  94.  
  95. //--------------------------------------------------------------------------------
  96. CDataPart::~CDataPart()
  97. {
  98. }
  99.  
  100. //--------------------------------------------------------------------------------
  101. void 
  102. CDataPart::Initialize(Environment* ev)    // Override
  103. {
  104.     FW_CPart::Initialize(ev);
  105.     FW_CSelection* selection = NULL;
  106.     const ODType kMainPresentation = "Apple:Presentation:Data";
  107.     const FW_Boolean kDefaultPresentation = true;
  108.     fPresentation = RegisterPresentation(ev, kMainPresentation, 
  109.                                             kDefaultPresentation, selection);
  110. }
  111.  
  112. //--------------------------------------------------------------------------------
  113. FW_Boolean 
  114. CDataPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)    // Override
  115. {
  116.     FW_Boolean menuHandled = true;
  117.     ODCommandID commandID = theMenuEvent.GetCommandID(ev);
  118.     
  119.     switch (commandID)
  120.     {
  121.         case kODCommandAbout:
  122.             ::FW_About(ev, this, kAbout);
  123.             break;
  124.  
  125.         default:
  126.             menuHandled = false;
  127.     }
  128.     
  129.     return menuHandled;
  130. }
  131.  
  132. //--------------------------------------------------------------------------------
  133. FW_CFrame* 
  134. CDataPart::NewFrame(Environment* ev, ODFrame* odFrame,
  135.                         FW_CPresentation* presentation, FW_Boolean fromStorage)    // Override
  136. {
  137.     FW_UNUSED(presentation);
  138.     FW_UNUSED(fromStorage);
  139.     return FW_NEW(CDataFrame, (ev, odFrame, presentation, fPartContent));
  140. }
  141.  
  142. //------------------------------------------------------------------------------
  143. FW_CContent* 
  144. CDataPart::NewPartContent(Environment* ev)
  145. {
  146.     fPartContent = FW_NEW(CDataContent, (ev, this));
  147.     return fPartContent;
  148. }
  149.  
  150. //------------------------------------------------------------------------------
  151. void 
  152. CDataPart::MyInvalidatePresentation(Environment* ev, FW_CRect& rect)
  153. {
  154.     fPresentation->Invalidate(ev, rect);
  155. }
  156.